﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

namespace outREACH.App_Code
{
    public class ContactUs
    {
        public string firstName { get; set; }
        public string lastName { get; set; }
        public string company { get; set; }
        public string email { get; set; }
        public string phone { get; set; }
        public string section { get; set; }
        public string statement { get; set; }
        public DateTime dateTime { get; set; }

        public static void InsertContactUs(ContactUs cu)
        {
            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                SqlCommand comm = new SqlCommand();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["outreachdbConnectionString"].ConnectionString;
                conn.Open();
                comm.Connection = conn;
                comm.CommandText = "insert into ContactUs(firstName, lastName, company, email, phone, section, statement, dateTime) VALUES (@firstName, @lastName, @company, @email, @phone, @section, @statement, @dateTime)";
                comm.Parameters.AddWithValue("@firstName", cu.firstName);
                comm.Parameters.AddWithValue("@lastName", cu.lastName);
                comm.Parameters.AddWithValue("@company", cu.company);
                comm.Parameters.AddWithValue("@email", cu.email);
                comm.Parameters.AddWithValue("@phone", cu.phone);
                comm.Parameters.AddWithValue("@section", cu.section);
                comm.Parameters.AddWithValue("@statement", cu.statement);
                comm.Parameters.AddWithValue("@dateTime", cu.dateTime);
                int rowsAffected = comm.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
    }
}